<%--
  Created by IntelliJ IDEA.
  User: 姜姒
  Date: 2022/5/10
  Time: 15:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxForm.js"></script>
    <script>
        layui.use(['form','laydate','layer'],function () {
            var form=layui.form,laydate=layui.laydate,layer=layui.layer;


            // //自定义验证规则
            // form.verify({
            //     chineseName: function (value) {
            //         let pattern = /[\u4e00-\u9fa5]/;//中文验证
            //         let txt = pattern.test(value);
            //
            //         if (value.length < 2 || !txt) {
            //             return '姓名必须是中文，且至少2个字符';
            //         }
            //     }
            //     });

            //定义自定义验证规则
            form.verify({
                chineseName: function (value) {
                    let pattern = /[\u4e00-\u9fa5]/;//中文验证
                    let txt = pattern.test(value);

                    if (value.length < 1 || !txt) {
                        return '维修设备必须要有中文';
                    }
                },
                // v_pass:[
                //     /^[\s]{0,3}$/,
                //     '学生ID必须是数字,且长度不能超过三位数'
                // ]
            });


            laydate.render({
                elem: '#entrytime',
                type: 'date',//指定日期选择器类型 date,time,datetime
                trigger: 'click'
            });
            laydate.render({
                elem: '#entrytime1',
                type: 'date',//指定日期选择器类型 date,time,datetime
                trigger: 'click'
            });

            $(function () {
                form.val('formsbt',${ep});//将对象赋给表单，自动赋值
                form.render();
            });


            form.on('submit(formBtn)',function(data){
                var formData = new FormData($("#formsbt")[0]);
                $.ajax({
                    url:'${pageContext.request.contextPath}/houqing/weixiuupd',
                    type : 'POST',
                    data : formData,
                    cache: false,
                    async: false,
                    processData : false,  //必须false才会避开jQuery对 formdata 的默认处理
                    contentType : false,  //必须false才会自动加上正确的Content-Type
                    success:function(data){
                        layer.msg('修改成功！',{icon:6,offset:"auto",time:2000});//提示框
                        setTimeout(function(){
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);//关闭弹出层
                            parent.location.reload();//重新加载父页面表格
                        }, 1100);
                    }
                })
                return false;
            });



            <%--//监听表单提交--%>
            <%--form.on('submit(formBtn)',function () {--%>
            <%--    $("#formsbt").ajaxSubmit({--%>
            <%--        type:"post",--%>
            <%--        url:'${pageContext.request.contextPath}/houqing/weixiuupd',--%>
            <%--        success:function(data) {--%>
            <%--            var index = parent.layer.getFrameIndex(window.name); // 获得frame索引--%>
            <%--            parent.layer.closeAll();//关闭当前from--%>
            <%--            parent.layui.table.reload('tableData'); // 可以对父窗口进行刷新--%>
            <%--            form.render();--%>
            <%--        }--%>
            <%--    });--%>
            <%--});--%>




        });
    </script>
</head>
<body>
<form class="layui-form" id="formsbt" lay-filter="formsbt">

    <div class="layui-form-item">
        <input type="hidden" name="equipmentId">
        <label class="layui-form-label">维修设备名:</label>
        <div class="layui-input-inline">
            <input type="text" name="equipmentType" class="layui-input" placaholder="请输入维修设备名称" lay-verify="required|chineseName"/>
        </div>
    </div>

<%--    <div class="layui-form-item">--%>
<%--        <label class="layui-form-label">维修状态:</label>--%>
<%--        <div class="layui-input-inline">--%>
<%--            <input type="text" name="status" class="layui-input" placaholder="0未完成,1已完成"/>--%>
<%--        </div>--%>
<%--        <div class="layui-form-mid layui-word-aux">0未完成,1已完成</div>--%>
<%--    </div>--%>

    <div class="layui-form-item">
        <label class="layui-form-label">班级:</label>
        <div class="layui-input-inline">
            <select name="classes">
                <c:forEach items="${sclist}" var="e">
                    <option value="${e.classId}">${e.className}</option>
                </c:forEach>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">学生:</label>
        <div class="layui-input-inline">
            <input type="text" name="student" value="${student}" readonly="readonly" class="layui-input" placaholder="请输入学生" lay-verify="required|v_pass"/>
        </div>
        <div class="layui-form-mid layui-word-aux">请输入学生id</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">备注:</label>
        <div class="layui-input-inline">
            <input type="text" name="remark" class="layui-input" placaholder="请输入备注"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">部门:</label>
        <div class="layui-input-inline">
            <select name="classes">
                <c:forEach items="${deplist}" var="e">
                    <option value="${e.depid}">${e.depName}</option>
                </c:forEach>
            </select>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">人员:</label>
            <div class="layui-input-inline">
                <select name="userType">
                    <option value="1">学生</option>
                    <option value="2">员工</option>
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">1学生 2员工</div>
        </div>


<%--    <div class="layui-form-item">--%>
<%--        <label class="layui-form-label">开始时间:</label>--%>
<%--        <div class="layui-input-inline">--%>
<%--            <input type="text" name="startTime" class="layui-input" id="entrytime"/>--%>
<%--        </div>--%>
<%--    </div>--%>



<%--    <div class="layui-form-item">--%>
<%--        <label class="layui-form-label">结束时间:</label>--%>
<%--        <div class="layui-input-inline">--%>
<%--            <input type="text" name="endTime" class="layui-input" id="entrytime1"/>--%>
<%--        </div>--%>
<%--    </div>--%>


    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="formBtn">申请</button>
        </div>
    </div>



</form>
<script>

</script>



</body>
</html>
